home *** CD-ROM | disk | FTP | other *** search
-
- #ifndef _MATRIX44_H_
- #define _MATRIX44_H_
- /*
- Peon - Win32 Games Programming Library
- Copyright (C) 2002-2005 Erik Yuzwa
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- Erik Yuzwa
- peon AT wazooinc DOT com
- */
-
- #include "Peonstdafx.h"
- #include "Vector3.h"
-
- namespace peon
- {
-
- /**
- * This is a bare-bones Matrix object which is of size 4x4.
- * It's not optimized, so use at your own risk but it demonstrates
- * how to use some basic matrix operations.
- *
- * The matrix is column-major which is exactly how the matrices are
- * represented in OpenGL. If you're porting this library over to
- * Direct3D, just remember that Direct3D's format is row-major.
- */
- class PEONMAIN_API Matrix44
- {
- public:
-
- /** our matrix data. It's in one contiguous element block. */
- float m[16];
-
- Matrix44(){ }
-
- Matrix44( float m0, float m4, float m8, float m12,
- float m1, float m5, float m9, float m13,
- float m2, float m6, float m10, float m14,
- float m3, float m7, float m11, float m15 );
-
- void identity(void);
- void translate(const Vector3 &trans);
- void translate_x(const float &dist);
- void translate_y(const float &dist);
- void translate_z(const float &dist);
- void rotate(const float &angle, Vector3 &axis);
- void rotate_x(const float &angle);
- void rotate_y(const float &angle);
- void rotate_z(const float &angle);
- void scale(const Vector3 &scale);
- void transformPoint( Vector3 *vec );
- void transformVector( Vector3 *vec );
-
- // Operators...
- Matrix44 operator + (const Matrix44 &other);
- Matrix44 operator - (const Matrix44 &other);
- Matrix44 operator * (const Matrix44 &other);
-
- Matrix44 operator * (const float scalar);
- };
-
-
-
- }
-
- #endif
-
-